package com.mike.employment.base.config;

import java.io.File;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class StaticResourceConfig extends WebMvcConfigurationSupport{

	public static final String separator = File.separator;
	@Value("${static.folder}")
    private String staticFolder;
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		String sourcePath = System.getProperty("user.dir") + separator +"src"+separator+ "main"+separator+"resources"+separator+ staticFolder;
		registry.addResourceHandler("/static/**").addResourceLocations("file:" + sourcePath + separator);
		super.addResourceHandlers(registry);
	}
}
